package com.zhiyou100.review.day020.homework;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;

/**
 * @packageName: Homework06
 * @className: com.zhiyou100.review.day020.homework
 * @Description: TODO 创建线程的四种方式
 * @author: yang
 * @date: 7/1/20
 */
public class Homework06 {

    public static void main(String[] args) {
        new Thread1().start();
        // 线程1

        new Thread(new Thread2()).start();
        // 线程 2

        new Thread(new FutureTask<Integer>(new Thread3())).start();
        // 线程3

        ExecutorService executorService = Executors.newFixedThreadPool(1);
        executorService.execute(new Runnable() {

            @Override
            public void run() {
                System.out.println("线程 4");
            }
        });
        executorService.shutdown();
        // 线程 四
    }

}

class Thread1 extends Thread {
    @Override
    public void run() {
        System.out.println("线程 1");
    }
}

class Thread2 implements Runnable {
    public Thread2() {
    }

    @Override
    public void run() {
        System.out.println("线程 2");
    }
}

class Thread3 implements Callable<Integer> {
    @Override
    public Integer call() throws Exception {
        System.out.println("线程 3");
        return 0;
    }
}


